<?php
/**
 * Created by PhpStorm.
 * User: xuho
 * Date: 2019-11-19
 * Time: 14:31
 */

namespace extend\time;


class Time extends \think\helper\Time
{
    /**
     * 返回月份时间戳
     * @param bool $date
     * @return array
     */
    public static function month($date = false)
    {
        if (!empty($date)) {
            $date = date('Y-m-t', strtotime($date));
        } else {
            $date = date('Y-m-t');
        }

        list($y, $m, $t) = explode('-', $date);
        return [
            mktime(0, 0, 0, $m, 1, $y),
            mktime(23, 59, 59, $m, $t, $y)
        ];
    }

    public static function dayScope($start_date, $end_date)
    {
        list($start_year, $start_month, $start_day) = explode('-', $start_date);
        list($end_year, $end_month, $end_day) = explode('-', $end_date);
        return [
            mktime(0, 0, 0, $start_month, $start_day, $start_year),
            mktime(23, 59, 59, $end_month, $end_day, $end_year)
        ];
    }
}